<template>
<div>
  <h1>评论</h1>
  <textarea name="" id="" cols="30" rows="10" v-model="form.text">输入评论内容</textarea>
  <button @click="add">确认</button>

<table>
  <tr>
    <td>用户</td>
    <td>评论内容</td>

  <tr v-for="i in list">
    <td>{{i.user}}</td>
    <td>{{i.text}}</td>
  </tr>
</table>

</div>
</template>

<script>
export default {
  name: "sspl",
  data(){
    return{
      form:{user:localStorage.getItem('userid'),goods:this.$route.query.goods},
      list:[]
    }
  },
  methods:{
    add(){
      this.$axios.post('users/SUser_API/',this.form)
      .then(i=>{
        if (i.data.code==200){
          alert("评论成功")
        }
        else {
          alert("评论失败")
        }
      })
    },
    show(){
      this.$axios.get('users/Spl_API/?user='+this.form.user+'&goods='+this.form.goods)
      .then(i=>{
        this.list = i.data.list

      })
    }
  },
  mounted() {
    this.show()
  }

}
</script>

<style scoped>

</style>
